using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class Forums_PostMap : EntityTypeConfiguration<Forums_Post>
    {
        public Forums_PostMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Text)
                .IsRequired();

            this.Property(t => t.IPAddress)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("Forums_Post");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.TopicId).HasColumnName("TopicId");
            this.Property(t => t.CustomerId).HasColumnName("CustomerId");
            this.Property(t => t.Text).HasColumnName("Text");
            this.Property(t => t.IPAddress).HasColumnName("IPAddress");
            this.Property(t => t.CreatedOnUtc).HasColumnName("CreatedOnUtc");
            this.Property(t => t.UpdatedOnUtc).HasColumnName("UpdatedOnUtc");

            // Relationships
            this.HasRequired(t => t.Customer)
                .WithMany(t => t.Forums_Post)
                .HasForeignKey(d => d.CustomerId);
            this.HasRequired(t => t.Forums_Topic)
                .WithMany(t => t.Forums_Post)
                .HasForeignKey(d => d.TopicId);

        }
    }
}
